/**
 * 
 */
package guice.command;

import com.google.inject.Inject;
import com.google.inject.Singleton;

/**
 * @author <a href='mailto:rahul.thakur.xdev@gmail.com'>Rahul Thakur</a>
 * @since 1.0
 * @version $Id$
 */
@Singleton
public class GenericInvoker {

	@Inject
	private CommandRegistry commandRegistry;

	public <REQ, RESP> RESP invokeCommand(Class<REQ> requestClass, REQ request, Class<RESP> responseClass) {

		System.out.println("CommandRegistry instance is: " + commandRegistry);

		ICommand<REQ, RESP> command = this.commandRegistry.getCommandInstance(requestClass, responseClass);

		command.setData(request);

		return command.execute();
	}
}
